package com.chen.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chen.entity.AccountA;
import com.chen.service.AccountAService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
@Api(value = "服务A测试接口",tags = "测试用")
public class TestController {

    @Autowired
    private AccountAService accountAService;

    @GetMapping("/hello")
    @ApiOperation(value = "hello接口",tags = "hello测试接口")
    public String test(){
        return "hello";
    }

    @GetMapping("/findByUserId/{userId}")
    @ApiOperation(value = "查询接口",tags = "查询测试接口")
    public String findByUserId(@PathVariable("userId") String userId){
        LambdaQueryWrapper<AccountA> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AccountA::getUserId,userId);
        AccountA accountA = accountAService.getOne(queryWrapper);
        return accountA.toString();
    }
}
